package com.zhoushihao.class0819;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

public class ReadFileDemo {
    public static void main(String[] args) {
        List<String> writerList = new ArrayList<>();
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader("./src/com/neusoft/zhoushihao/class0819/WriteFileDemo.java"))) {
            String line;
            line = bufferedReader.readLine();
            while (line != null) {
                if (!line.contains("//")) {
                    writerList.add(line);
                }
                line = bufferedReader.readLine();
            }
        }catch(Exception e) {
            throw new RuntimeException(e);
        }
        try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("./src/com/neusoft/zhoushihao/class0819/WriteFileDemo.java"))){
            for (String str : writerList) {
                bufferedWriter.write(str);
                bufferedWriter.newLine();
            }
        }catch(Exception e) {
            throw new RuntimeException(e);
        }
    }
}
